import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/ui/service_order/service_order_list_page.dart';
import 'package:ls_work/viewmodel/service_order/service_order_list_home_view_model.dart';

class ServiceOrderListHomePage extends BaseStatefulMvvmWidget {
  @override
  State<StatefulWidget> createState() => _ServiceOrderListHomeState();
}

class _ServiceOrderListHomeState extends BaseMvvmState<
    ServiceOrderListHomeViewModel,
    ServiceOrderListHomePage> with SingleTickerProviderStateMixin {
  TabController? controller;

  List<String> get titles => ["全部", "待接单", "待服务", "服务中", "已完成"];

  @override
  void initState() {
    controller = TabController(length: titles.length, vsync: this);
    super.initState();
  }

  @override
  Widget buildLoadingContentView() {
    return Column(
      children: [
        Gaps.line,
        Material(
          color: Colors.white,
          child: PreferredSize(child: TabBar(
            tabs: titles
                .map((e) => Tab(
              text: e,
            ))
                .toList(),
            indicator: BoxDecoration(),
            controller: controller,
            unselectedLabelColor: Color(0xff95989D),
            labelColor: Colours.app_main,
            labelStyle: TextStyle(fontWeight: FontWeight.w600,fontSize: 13),
            unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal,fontSize: 13),
          ),preferredSize: Size.fromHeight(35),),
        ),
        TabBarView(
          children: [
            ServiceOrderListPage("888"),
            ServiceOrderListPage("10233"),
            ServiceOrderListPage("555"),
            ServiceOrderListPage("10236"),
            ServiceOrderListPage("10242"),
          ],
          controller: controller,
        ).setWeight(1)
      ],
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  ServiceOrderListHomeViewModel createViewModel() {
    return ServiceOrderListHomeViewModel(context);
  }

  @override
  void onRetryClick() {}
}
